<script setup lang="ts">
import { RouterView, useRoute } from 'vue-router'
import { computed } from 'vue'

const route = useRoute()

// 判断是否为需要全屏显示的页面（MES管理页面和登录页面）
const isFullScreenPage = computed(() =>
  route.path.startsWith('/mes') || route.path === '/login'
)
</script>

<template>
  <div id="app">
    <!-- 只在非全屏页面显示简洁导航 -->
    <div v-if="!isFullScreenPage" class="default-layout">
      <nav class="top-nav">
        <div class="nav-brand">
          <h2>MES管理系统</h2>
        </div>
        <div class="nav-links">
          <RouterLink to="/">首页</RouterLink>
          <RouterLink to="/about">关于</RouterLink>
          <RouterLink to="/login">登录</RouterLink>
          <RouterLink to="/mes">MES管理</RouterLink>
        </div>
      </nav>
    </div>

    <!-- 路由视图 -->
    <RouterView />
  </div>
</template>

<style>
/* 全局应用样式，不使用scoped */
#app {
  width: 100vw !important;
  height: 100vh !important;
  overflow: hidden !important;
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  display: block !important;
  grid-template-columns: none !important;
}

.default-layout {
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 10;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px;
  background: white;
}

.nav-brand h2 {
  color: #2c3e50;
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-links a {
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  color: #606266;
  font-weight: 500;
  transition: all 0.3s;
}

.nav-links a.router-link-exact-active {
  color: #409EFF;
  background-color: #ecf5ff;
}

.nav-links a:hover {
  color: #409EFF;
  background-color: #f5f7fa;
}

/* MES页面特定样式 */
.mes-management {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 1000;
}

@media (max-width: 768px) {
  .top-nav {
    flex-direction: column;
    gap: 15px;
    padding: 15px 20px;
  }

  .nav-brand h2 {
    font-size: 1.3rem;
  }

  .nav-links {
    gap: 15px;
  }
}
</style>
